<template>
  <a-spin :spinning="confirmLoading">
    <j-form-container :disabled="false">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail">
        <a-collapse v-model="activeKey">
          <a-collapse-panel key="1" header="基础信息">
            <a-row :gutter="48">
              <a-col :span="8">
                <a-form-model-item label="姓名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="name">
                  <a-input :disabled="formDisabled" v-model="model.name" placeholder="请输入姓名"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="性别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="gender">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.gender"
                    dictCode="gender"
                    placeholder="请选择性别"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="照片" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="photo">
                  <j-image-upload :disabled="formDisabled" isMultiple v-model="model.photo"></j-image-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="民族" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="national">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.national"
                    dictCode="national"
                    placeholder="请选择民族"
                  />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="籍贯" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="nativePlace">
                  <j-area-linkage :disabled="formDisabled" type="cascader" v-model="model.nativePlace" placeholder="请选择籍贯"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="身份证号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardNo">
                  <a-input :disabled="formDisabled" v-model="model.idCardNo" placeholder="请输入身份证号" @input="inputIdCardNo"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="身份证到期日" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="idCardNoDue">
                  <j-date :disabled="formDisabled" @change="idCardNoDueChange" placeholder="请选择身份证到期日" v-model="model.idCardNoDue" style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="出生日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="birthDate">
                  <j-date :disabled="formDisabled" placeholder="请选择出生日期" v-model="model.birthDate" style="width: 100%" disabled/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="工作年限" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workTime">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.workTime"
                    dictCode="work_time"
                    placeholder="请选择工作年限"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="收款户名" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payeeName">
                  <a-input :disabled="formDisabled" v-model="model.payeeName" placeholder="请输入收款户名"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="银行卡号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankCard">
                  <a-input type="number" :disabled="formDisabled" v-model="model.bankCard" placeholder="请输入银行卡号" style="width:100%"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="开户行联行号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cnapsCode">
                  <SelectFinanceKingdeeBankInput :disabled=formDisabled v-model="model.cnapsCode" :max-length="64"  placeholder="请选择联行号"  @back="backCnapsCode"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="开户行" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bankName">
                  <a-input :disabled="formDisabled" v-model="model.bankName" placeholder="请输入开户行" disabled></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="政治面貌" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="politicalLandscape">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.politicalLandscape"
                    dictCode="political_landscape"
                    placeholder="请选择政治面貌"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="婚姻状况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="maritalStatus">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.maritalStatus"
                    dictCode="marital_status"
                    placeholder="请选择婚姻状况"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="身高" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="height">
                  <a-input :disabled="formDisabled" v-model="model.height" placeholder="请输入身高"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="血型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="bloodType">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.bloodType"
                    dictCode="blood_type"
                    placeholder="请选择血型"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="特长爱好" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hobby">
                  <a-textarea :disabled="formDisabled" v-model="model.hobby" rows="4" placeholder="请输入特长爱好"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="家族遗传病史"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="hasFamilyGeneticHistory">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasFamilyGeneticHistory"
                    dictCode="YES_OR_NO"
                    placeholder="请选择家族遗传病史"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="传染病史"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="hasInfectiousHistory">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasInfectiousHistory"
                    dictCode="YES_OR_NO"
                    placeholder="请选择家传染病史"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="既往病史"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="hasPastMedicalHistory">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasPastMedicalHistory"
                    dictCode="YES_OR_NO"
                    placeholder="请选择既往病史"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="犯罪记录" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hasCriminalRecord">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasCriminalRecord"
                    dictCode="YES_OR_NO"
                    placeholder="请选择犯罪记录"/>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="2" header="资历状况">
            <a-row :gutter="48">
              <a-col :span="8">
                <a-form-model-item label="外语水平" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="foreignLanguageLevel">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.foreignLanguageLevel" dictCode="foreign_language_level" placeholder="请选择外语水平" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="计算机能力" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="computerCapability">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.computerCapability" dictCode="computer_capability" placeholder="请选择计算机能力" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="驾照情况" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="hasDrivingLicense">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.hasDrivingLicense"
                    dictCode="YES_OR_NO"
                    placeholder="请选择驾照情况"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="资格证书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="qualification">
                  <a-input :disabled="formDisabled" v-model="model.qualification" placeholder="请输入资格证书"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="职称" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="professionalTitle">
                  <a-input :disabled="formDisabled" v-model="model.professionalTitle" placeholder="请输入职称"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="毕业院校" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="graduatedFrom">
                  <a-input :disabled="formDisabled" v-model="model.graduatedFrom" placeholder="请输入毕业院校"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="所学专业" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="major">
                  <a-input :disabled="formDisabled" v-model="model.major" placeholder="请输入专业"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="毕业时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="graduationDate">
                  <j-date
                    :disabled="formDisabled"
                    placeholder="请选择毕业时间"
                    v-model="model.graduationDate"
                    style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="最高学历/学位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="highestDegree">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.highestDegree"
                    dictCode="highest_degree"
                    placeholder="请选择最高学历"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="教育方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="educationalMode">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.educationalMode"
                    dictCode="educational_mode"
                    placeholder="请选择教育方式"/>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="3" header="组织信息" >
            <a-row :gutter="48">
              <a-col :span="8">
                <a-form-model-item label="人员编号" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeNo">
                  <a-input :disabled="formDisabled" v-model="model.employeeNo" placeholder="请输入人员编号"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="入职时间" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="joinDate">
                  <j-date :disabled="formDisabled" placeholder="请选择入职时间" v-model="model.joinDate" style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="转正日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="probationEndDate">
                  <j-date
                    :disabled="formDisabled"
                    placeholder="请选择转正日期"
                    v-model="model.probationEndDate"
                    style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="8">
                <a-form-model-item label="所属单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="orgDepart">
                  <j-select-depart :disabled=formDisabled v-model="model.orgDepart"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="所属部门" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="departmentId">
                  <j-select-depart :disabled=formDisabled v-model="model.departmentId" :multi="true"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="所属团队" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="teamId">
                  <select-team-input :disabled="formDisabled" v-model="model.teamId" :tdlx="3" />
                </a-form-model-item>
              </a-col> -->
              <a-col :span="8">
                <a-form-model-item label="人员类型" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeType">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.employeeType"
                    dictCode="employee_type"
                    placeholder="请选择人员类型"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="人员状态" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="employeeStatus">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.employeeStatus"
                    dictCode="employee_status"
                    @input="employeeStatusChangeHandle"
                    placeholder="请选择人员状态"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8" v-if="model.employeeStatus == '2'">
                <a-form-model-item label="离职日期" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="resignTime">
                  <j-date
                    :disabled="formDisabled"
                    placeholder="请选择离职日期"
                    v-model="model.resignTime"
                    style="width: 100%"/>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="8">
                <a-form-model-item label="职务级别" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="positionLevelId">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.positionLevelId"
                    dictCode="erp_org_position_level,level_name,id,del_flag='0' and audit_status='2'"
                    placeholder="请选择职务级别"/>
                </a-form-model-item>
              </a-col> -->
              <!-- <a-col :span="8">
                <a-form-model-item label="主岗" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="mainPost">
                  <j-dict-select-tag :disabled="formDisabled" type="list" v-model="model.mainPost"
                                     dictCode="sys_position,name,id,del_flag = 0 and audit_status=2" placeholder="请选择主岗"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="副岗" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="deputyPost">
                  <j-multi-select-tag :disabled="formDisabled" type="select" v-model="model.deputyPost"
                                     dictCode="sys_position,name,id,del_flag = 0 and audit_status=2" placeholder="请选择副岗"/>
                </a-form-model-item>
              </a-col> -->
              <a-col :span="8">
                <a-form-model-item label="工作地" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="workplace">
                  <a-input :disabled="formDisabled" v-model="model.workplace" placeholder="请输入工作地"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="薪级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="payGradeId">
                  <j-dict-select-tag :disabled="formDisabled" v-model="model.payGradeId" placeholder="请选择薪级" dictCode="erp_pay_grade,salary_grade,id,del_flag = 0 and audit_status=2 order by sort"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="对应薪级" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="parallelismPayGrades">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    @input="salaryChangeHandle"
                    v-model="model.parallelismPayGrades"
                    dictCode="salary_level"
                    placeholder="请选择对应薪级"/>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="车贴（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="carSubsidy">
                  <!--                  <a-input :disabled="formDisabled" v-model="model.carSubsidy" placeholder="请输入车贴"></a-input>-->
                  <a-input-number
                    :disabled="formDisabled"
                    :max="99999999"
                    :min="0"
                    v-model="model.carSubsidy"
                    placeholder="请输入车贴"
                    style="width: 100%" />
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item
                  label="是否外派"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="expatriate">
                  <j-dict-select-tag
                    :disabled="formDisabled"
                    type="list"
                    v-model="model.expatriate"
                    dictCode="YES_OR_NO"
                    placeholder="请选择是否外派"/>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="8">
                <a-form-model-item label="汇报人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="reportId">
                  <select-user-by-dep :disabled=formDisabled  :multi="false"
                  v-model="model.reportId"></select-user-by-dep>
                </a-form-model-item>
              </a-col> -->
              <!-- <a-col :span="8">
                <a-form-model-item
                  label="公积金单位"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="providentFundUnit"
                >
                  <select-Company-input :disabled="formDisabled" v-model="model.providentFundUnit" />
                </a-form-model-item>
              </a-col> -->
              <!-- <a-col :span="8">
                <a-form-model-item label="参保单位" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="insuredUnit">
                  <select-Company-input :disabled="formDisabled" v-model="model.insuredUnit" />
                </a-form-model-item>
              </a-col> -->
              <!-- <a-col :span="8">
                <a-form-model-item label="参保基数（元）" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="insuredBase">
                  <a-input :disabled="formDisabled" v-model="model.insuredBase" placeholder="请输入参保基数"></a-input>
                </a-form-model-item>
              </a-col> -->
              <!-- <a-col :span="8">
                <a-form-model-item
                  label="公积金基数（元）"
                  :labelCol="labelCol"
                  :wrapperCol="wrapperCol"
                  prop="providentFundBase"
                >
                  <a-input
                    :disabled="formDisabled"
                    v-model="model.providentFundBase"
                    placeholder="请输入公积金基数"
                  ></a-input>
                </a-form-model-item>
              </a-col> -->
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="4" header="单位信息">
            <a-divider>参保单位</a-divider>
            <ErpEmployeeInsuredUnitInfoList
              :employeeId="model.id"
              :newData="model.cbUnitInfoList"
              @delete="listDelete($event,'cbUnitInfoList')"
              @ok="listOk($event,'cbUnitInfoList')"
              :disabledButton="formDisabled"></ErpEmployeeInsuredUnitInfoList>
            <!-- <a-divider>发薪单位</a-divider>
            <ErpEmployeeSalaryPayingUnitInfoList
              :employeeId="model.id"
              :newData="model.fxUnitInfoList"
              @delete="listDelete($event,'fxUnitInfoList')"
              @ok="listOk($event,'fxUnitInfoList')"
              :disabledButton="formDisabled"></ErpEmployeeSalaryPayingUnitInfoList> -->
            <a-divider>公积金单位</a-divider>
            <ErpEmployeeProvidentFundUnitInfoList
              :employeeId="model.id"
              :newData="model.gjjUnitInfoList"
              @delete="listDelete($event,'gjjUnitInfoList')"
              @ok="listOk($event,'gjjUnitInfoList')"
              :disabledButton="formDisabled"></ErpEmployeeProvidentFundUnitInfoList>
          </a-collapse-panel>
          <a-collapse-panel key="5" header="联系信息">
            <a-row :gutter="48">
              <a-col :span="8">
                <a-form-model-item label="手机号码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.mobile">
                  <a-input
                    :disabled="formDisabled"
                    v-model="model.contactInfo.mobile"
                    placeholder="请输入手机号码"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="紧急联系人" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.linkPerson">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.linkPerson" placeholder="请输入紧急联系人姓名"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="紧急联系人方式" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.linkTel">
                  <a-input
                    :disabled="formDisabled"
                    v-model="model.contactInfo.linkTel"
                    placeholder="请输入紧急联系人方式"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="8">
                <a-form-model-item label="电子邮件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.email">
                  <a-input
                    :disabled="formDisabled"
                    v-model="model.contactInfo.email"
                    placeholder="请输入电子邮件"></a-input>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <a-form-model-item label="身份证地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.idCardAddress">
                  <a-input
                    :disabled="formDisabled"
                    v-model="model.contactInfo.idCardAddress"
                    placeholder="请输入身份证地址"></a-input>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="24">
                <a-form-model-item label="邮政编码" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.zipCode">
                  <a-input :disabled="formDisabled" v-model="model.contactInfo.zipCode"
                           placeholder="请输入邮政编码"></a-input>
                </a-form-model-item>
              </a-col> -->
              <a-col :span="24">
                <a-form-model-item label="现居地详细地址" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="contactInfo.currentAddress">
                  <a-input
                    :disabled="formDisabled"
                    v-model="model.contactInfo.currentAddress"
                    placeholder="请输入现居地详细地址"></a-input>
                </a-form-model-item>
              </a-col>
            </a-row>
          </a-collapse-panel>
          <a-collapse-panel key="6" header="家庭成员与社会关系">
            <erp-employee-family-social-info-list
              ref="familySocialInfo"
              :employeeId="model.id"
              :newData="model.familySocialInfoList"
              @delete="listDelete($event,'familySocialInfoList')"
              @ok="listOk($event,'familySocialInfoList')"
              :disabledButton="formDisabled"></erp-employee-family-social-info-list>
          </a-collapse-panel>
          <a-collapse-panel key="7" header="工作经历">
            <erp-employee-work-history-list
              ref="workHistory"
              :employeeId="model.id"
              :newData="model.workHistoryList"
              @delete="listDelete($event,'workHistoryList')"
              @ok="listOk($event,'workHistoryList')"
              :disabledButton="formDisabled"></erp-employee-work-history-list>
          </a-collapse-panel>
          <a-collapse-panel key="8" header="教育经历">
            <erp-employee-education-list
              ref="education"
              :employeeId="model.id"
              :newData="model.educationList"
              @delete="listDelete($event,'educationList')"
              @ok="listOk($event,'educationList')"
              :disabledButton="formDisabled"></erp-employee-education-list>
          </a-collapse-panel>
          <a-collapse-panel key="9" header="培训经历">
            <erp-employee-training-list
              ref="training"
              :employeeId="model.id"
              :newData="model.trainingList"
              @delete="listDelete($event,'trainingList')"
              @ok="listOk($event,'trainingList')"
              :disabledButton="formDisabled"></erp-employee-training-list>
          </a-collapse-panel>
          <a-collapse-panel key="10" header="职务变动">
            <erp-employee-position-change-record-list
              ref="positionChangeRecord"
              :employeeId="model.id"
              :newData="model.positionChangeRecordList"
              @delete="listDelete($event,'positionChangeRecordList')"
              @ok="listOk($event,'positionChangeRecordList')"
              :disabledButton="formDisabled"></erp-employee-position-change-record-list>
          </a-collapse-panel>
          <a-collapse-panel key="11" header="岗位信息">
            <erp-employee-post-change-record-list
              ref="postChangeRecord"
              :employeeId="model.id"
              :newData="model.postChangeRecordList"
              @delete="listDelete($event,'postChangeRecordList')"
              @ok="listOk($event,'postChangeRecordList')"
              :disabledButton="formDisabled"></erp-employee-post-change-record-list>
          </a-collapse-panel>
          <a-collapse-panel key="12" header="奖惩档案">
            <erp-employee-reward-punish-file-list
              ref="rewardPunish"
              :employeeId="model.id"
              :newData="model.rewardPunishFileList"
              @delete="listDelete($event,'rewardPunishFileList')"
              @ok="listOk($event,'rewardPunishFileList')"
              :disabledButton="formDisabled"></erp-employee-reward-punish-file-list>
          </a-collapse-panel>
          <a-collapse-panel key="13" header="资质证书">
            <erp-employee-certificate-list
              ref="certificate"
              :employeeId="model.id"
              :newData="model.employeeCertificateList"
              @delete="listDelete($event,'employeeCertificateList')"
              @ok="listOk($event,'employeeCertificateList')"
              :disabledButton="formDisabled"></erp-employee-certificate-list>
          </a-collapse-panel>
          <a-collapse-panel key="14" header="附件信息">
            <div>
              <div style="color: #f5222d;margin-bottom: 10px;">提示：请等待附件上传完成，再点击保存，否则附件无法保存成功！</div>
            </div>
            <a-row :gutter="48">
              <a-col :span="6">
                <a-form-model-item label="身份证复印件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.idCard">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.idCard" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="毕业证复印件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.graduate">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.graduate" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="学位证复印件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.degree">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.degree" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="学信网学历验证报告" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.xuexin">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.xuexin" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <h3 style="font-weight: 600;">入职附件</h3>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="最后任职公司的离职证明" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.resign">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.resign" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="体检报告" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.medicalReport">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.medicalReport" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="证件数码底版" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.certificateBottom">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.certificateBottom" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>

              <a-col :span="6">
                <a-form-model-item label="劳动合同复印件" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.employmentContract">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.employmentContract" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="培训协议" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.training">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.training" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="保密协议" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.confidentiality">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.confidentiality" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="竞业限制协议" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.competeRestrictions">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.competeRestrictions" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="签字确认的offer" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.signOffer">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.signOffer" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="证书" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.certificate">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.certificate" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="其它" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.other">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.other" :showToast="false" fileFormat=".pdf, .PDF"></j-upload>
                </a-form-model-item>
              </a-col>
              <!-- <a-col :span="24">
                <h3 style="font-weight: 600;">试用期附件</h3>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="试用期目标确认表" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.targetConfirm">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.targetConfirm" :showToast="false"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="试用期考核表" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.assessment">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.assessment" :showToast="false"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="薪资确认单" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.salaryConfirm">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.salaryConfirm" :showToast="false"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="24">
                <h3 style="font-weight: 600;">交接附件</h3>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="岗位调动交接表" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.postTransfer">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.postTransfer" :showToast="false"></j-upload>
                </a-form-model-item>
              </a-col>
              <a-col :span="6">
                <a-form-model-item label="离职交接表" :labelCol="labelCol" :wrapperCol="wrapperCol" prop="attachment.resignHandover">
                  <j-upload :disabled="formDisabled" v-model="model.attachment.resignHandover" :showToast="false"></j-upload>
                </a-form-model-item>
              </a-col> -->
            </a-row>
          </a-collapse-panel>
        </a-collapse>
      </a-form-model>

    </j-form-container>
  </a-spin>
</template>

<script>

import { getAction, httpAction } from '@/api/manage'
import { validateBlankValue, validateDuplicateValue } from '@/utils/util'
import ErpEmployeeFamilySocialInfoList from '@/views/erp/files/employee/ErpEmployeeFamilySocialInfoList';
import ErpEmployeeInsuredUnitInfoList from '@/views/erp/files/employee/ErpEmployeeInsuredUnitInfoList';  // 参保单位信息
import ErpEmployeeSalaryPayingUnitInfoList from '@/views/erp/files/employee/ErpEmployeeSalaryPayingUnitInfoList';  // 发薪单位信息
import ErpEmployeeProvidentFundUnitInfoList from '@/views/erp/files/employee/ErpEmployeeProvidentFundUnitInfoList';  // 公积金单位信息
import ErpEmployeeWorkHistoryList from '@/views/erp/files/employee/ErpEmployeeWorkHistoryList';
import ErpEmployeeEducationList from '@/views/erp/files/employee/ErpEmployeeEducationList';
import ErpEmployeePostChangeRecordList from '@/views/erp/files/employee/ErpEmployeePostChangeRecordList';
import ErpEmployeePositionChangeRecordList from '@/views/erp/files/employee/ErpEmployeePositionChangeRecordList';
import ErpEmployeeRewardPunishFileList from '@/views/erp/files/employee/ErpEmployeeRewardPunishFileList';
import ErpEmployeeCertificateList from '@/views/erp/files/employee/ErpEmployeeCertificateList';
import ErpEmployeeTrainingList from '@/views/erp/files/employee/ErpEmployeeTrainingList';
import SelectTeamInput from '@/views/scy/components/SelectTeamInput';
import SelectPersonInput from '@/views/scy/components/SelectPersonInput'
import SelectCompanyInput from '@/views/scy/components/SelectCompanyInput'
import SelectUserByDep from '@/views/scy/components/SelectUserByDep'
import { filterMultiDictText, initDictOptions } from '@/components/dict/JDictSelectUtil'
import SelectFinanceKingdeeBankInput from '@/views/scy/components/SelectFinanceKingdeeBankInput'

export default {
  name: 'ErpEmployeeFileForm',
  components: {
    SelectFinanceKingdeeBankInput,
    SelectUserByDep,
    SelectCompanyInput,
    ErpEmployeeTrainingList,
    ErpEmployeePostChangeRecordList,
    ErpEmployeeCertificateList,
    ErpEmployeeRewardPunishFileList,
    ErpEmployeePositionChangeRecordList,
    ErpEmployeeEducationList,
    ErpEmployeeWorkHistoryList,
    ErpEmployeeFamilySocialInfoList,
    ErpEmployeeInsuredUnitInfoList,
    ErpEmployeeSalaryPayingUnitInfoList,
    ErpEmployeeProvidentFundUnitInfoList,
    SelectTeamInput,
    SelectPersonInput
  },
  props: {
    // 表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      activeKey: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13'],
      model: {
        accountStatus: 'enabled',
        maritalStatus: '2',
        hasFamilyGeneticHistory: '0',
        hasInfectiousHistory: '0',
        hasPastMedicalHistory: '0',
        hasCriminalRecord: '0',
        expatriate: '0',
        gender: 'male',
        contactInfo: {},
        educationList: [],
        familySocialInfoList: [],
        positionChangeRecordList: [],
        rewardPunishFileList: [],
        trainingList: [],
        workHistoryList: [],
        employeeCertificateList: [],
        postChangeRecordList: [],
        attachment: {
          employeeId: ''
        }
      },
      labelCol: {},
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 24 }
      },
      confirmLoading: false,
      validatorRules: {
        name: [
          { required: true, message: '请输入姓名!' },
          { validator: (rule, value, callback) => validateBlankValue('erp_employee_file', 'name', value, this.model.id, callback) }
        ],
        politicalLandscape: [
          { required: true, message: '请选择政治面貌!' }
        ],
        national: [
          { required: true, message: '请选择名族!' }
        ],
        nativePlace: [
          { required: true, message: '请选择籍贯!' }
        ],
        employeeNo: [
          { required: true, message: '请输入员工编号!' },
          { validator: (rule, value, callback) => validateDuplicateValue('erp_employee_file', 'employee_no', value, this.model.id, callback) }
        ],
        idCardNo: [
          { required: true, message: '请输入身份证号!' },
          { validator: (rule, value, callback) => validateDuplicateValue('erp_employee_file', 'id_card_no', value, this.model.id, callback) },
          { pattern: '^\\d{6}(18|19|20)?\\d{2}(0[1-9]|1[012])(0[1-9]|[12]\\d|3[01])\\d{3}(\\d|[xX])$', message: '身份证号格式不正确' }
        ],
        payeeName: [
          { required: true, message: '请输入员工的收款户名!' },
        ],
        idCardNoDue: [
          { required: true, message: '请选择身份证到期日!' }
        ],
        cnapsCode: [
          { required: true, message: '请选择员工的银行开户行联行号!' },
        ],
        bankName: [
          { required: true, message: '请输入员工的银行开户行!' },
        ],
        bankCard: [ { required: true, message: '请输入银行卡号!' },{ pattern: /^[1-9]{1}\d{7,50}$/, message: '银行卡号格式不正确' } ],
        departmentId: [
          { required: true, message: '请选择所属部门!' }
        ],
        orgDepart: [
          { required: true, message: '请选择所属单位!' }
        ],
        positionLevelId: [
          { required: true, message: '请选择职务级别!' }
        ],
        joinDate: [
          { required: true, message: '请选择入职时间!' }
        ],
        probationEndDate: [
          { required: true, message: '请选择转正时间!' }
        ],
        mainPost: [
          { required: true, message: '请选择主岗!' }
        ],
        deputyPost: [
          { required: true, message: '请选择副岗!' }
        ],
        expatriate: [
          { required: true, message: '请选择是否外派!' }
        ],
        payGradeId: [
          { required: true, message: '请选择薪级!' }
        ],
        workplace: [
          { required: true, message: '请输入工作地!' }
        ],
        teamId: [
          { required: true, message: '请选择所属团队!' }
        ],
        employeeType: [
          { required: true, message: '请选择人员状态!' }
        ],
        resignTime: [
          { required: true, message: '请选择离职日期!' }
        ],
        carSubsidy: [
          { required: false, pattern: /^(([1-9][0-9]*|0)|([0]\.\d{0,2}|[1-9][0-9]*\.\d{0,2}))$/, message: '请输入正确的金额！' }
        ],
        employeeStatus: [
          { required: true, message: '请选择人员类型!' }
        ],
        // reportId: [
        //   { required: true, message: '请选择汇报人!' }
        // ],
        providentFundUnit: [
            { required: true, message: '请选择公积金单位!' }
        ],
        providentFundBase: [
            { required: true, message: '请选择公积金基数!' }
        ],
        insuredUnit: [
            { required: true, message: '请选择参保单位!' }
        ],
        insuredBase: [
            { required: true, message: '请选择参保基数!' }
        ],
        contactInfo: {
          mobile: [{ required: true, pattern: /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/, message: '请输入正确手机号', trigger: 'blur' }],
          linkPerson: [
            { required: true, message: '请输入紧急联系人姓名!' }
          ],
          linkTel: [{ required: true, pattern: /^1\d{10}$|^(0\d{2,3}-?|\(0\d{2,3}\))?[1-9]\d{4,7}(-\d{1,8})?$/, message: '请输入正确手机号', trigger: 'blur' }],
          email: [{ required: true, pattern: /^([a-zA-Z0-9._-])+@([a-zA-Z0-9_-])+((.[a-zA-Z0-9_-]{2,3}){1,2})$/, message: '请输入正确邮件地址', trigger: 'blur' }],
          idCardAddress: [{ required: true, message: '请输入身份证地址', trigger: 'blur' }],
          currentAddress: [{ required: true, message: '请输入身份证地址', trigger: 'blur' }]
        }
        // collapsePanel: [
        //   { required: true, message: '组织信息!' }
        // ]
      },
      url: {
        add: '/api/erp/files/employee/erpEmployeeFile/add',
        edit: '/api/erp/files/employee/erpEmployeeFile/edit',
        queryById: '/api/erp/files/employee/erpEmployeeFile/queryById',
        getEmployeeNoUrl: '/api/erpmng/sys/common/getDataSequenceNoByLen'
      },
      salaryDictList: []
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    }
  },

  created() {
    // 备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model));
    this.initDictConfig();
  },
  methods: {
    backCnapsCode(data){
      if(data){
        this.$set(this.model, 'bankName', data[0].bankBranchName)
      }
    },
    employeeStatusChangeHandle() {
      
    },
    inputIdCardNo() {
      if (this.model.idCardNo) {
        let idCardNo = this.model.idCardNo;
        if (idCardNo.length >= 18) {
          let birthDate = idCardNo.substr(6, 4) + '-' + idCardNo.substr(10, 2) + '-' + idCardNo.substr(12, 2);
          this.$set(this.model, 'birthDate', birthDate);
        } else {
          this.$set(this.model, 'birthDate', null);
        }
      } else {
        this.$set(this.model, 'birthDate', null);
      }
    },
    // 选择对应薪级带出车贴
    salaryChangeHandle(v) {
      if (this.salaryDictList) {
        let temp = this.salaryDictList.filter(item => item.value == v)
        this.$set(this.model, 'carSubsidy', temp[0].value)
      }
    },
    async initDictConfig() {
      initDictOptions('salary_level').then(async(res) => {
        if (res.success) {
          this.salaryDictList = res.result
        }
      })
    },
    listOk(val, key) {
      this.model[key] = val
    },
    listDelete(val, key) {
      this.model[key] = val
    },
    add() {
      this.getEmployeeNo()
      this.model = {
        idCardNoDue: '', // 身份证有效期
        accountStatus: 'enabled',
        maritalStatus: '2',
        hasFamilyGeneticHistory: '0',
        hasInfectiousHistory: '0',
        hasPastMedicalHistory: '0',
        hasCriminalRecord: '0',
        expatriate: '0',
        gender: 'male',
        contactInfo: {},
        educationList: [],
        familySocialInfoList: [],
        positionChangeRecordList: [],
        rewardPunishFileList: [],
        trainingList: [],
        workHistoryList: [],
        employeeCertificateList: [],
        postChangeRecordList: [],
        attachment: {
          employeeId: ''
        }
      }
      this.$refs.form.clearValidate()
    },
    edit(record) {
      // await  this.clearPanelListDataSource()
      // this.$refs.form.resetFields();
      // this.model = Object.assign({}, record);
      // if (!this.model.contactInfo) {
      //   this.model.contactInfo = {}
      // }
      // this.clearPanelListDataSource()
      this.$refs.form.clearValidate()
      this.model.attachment.employeeId = record.id
      getAction(this.url.queryById, { id: record.id }).then(res => {
        if (res.success) {
          delete res.result.postChangeRecordList
          this.model = Object.assign({}, res.result)
          this.getPostList()
          if (!this.model.employeeNo) {
            this.getEmployeeNo();
          }
        }
      })
      this.visible = true;
    },
    getEmployeeNo() {
      getAction(this.url.getEmployeeNoUrl, { 'prefix': 'HM', 'key': 'hmEmp:sequence:no', 'len': 5 }).then((res) => {
        if (res.success) {
          let data = res.result
          // debugger;
          this.$set(this.model, 'employeeNo', data)
          this.$set(this.modelDefault, 'employeeNo', data)
        }
      })
    },
    // 获取岗位信息
    getPostList() {
      var params = {
        isVirtual: '0', // 是否虚拟岗位为否
        postDataSource: 'employee', // 数据来源为在职员工档案
        isDuty: 'all',
        employeeId: this.model.id // 员工id
      }
      // 判断当为离职的时候传字段employeeStatus：0
      if (this.model.employeeStatus && this.model.employeeStatus == '2') {
        params.employeeStatus = '2'
      }
      getAction('/api/erp/files/employee/erpEmployeePostChangeRecord/queryPostRecordByVo', params).then((res) => {
        if (res.success) {
          this.$set(this.model, 'postChangeRecordList', res.result)
        }
      })
    },
    // 选择身份证有效期
    idCardNoDueChange(date) {
      this.model.idCardNoDue = date
    },
    checkSingleFlag(arr) {
      let count = 0;
      for (let i = 0; i < arr.length; i++) {
        if (arr[i].currFlag == 1) {
          count++;
          // 如果已经有两个元素的 currFlag 等于 1，直接返回 false
          if (count > 1) {
            return false;
          }
        }
      }
      return count <= 1;
    },
    submitForm() {
      const that = this;
      // 触发表单验证
      this.$refs.form.validate(valid => {
        // if(that.model.familySocialInfoList.length === 0) {
        //   that.$message.warning('请填写家庭成员与社会关系')
        //   return
        // }
        // if(that.model.workHistoryList.length === 0) {
        //   that.$message.warning('请填写工作经历')
        //   return
        // }
        // if(that.model.educationList.length === 0) {
        //   that.$message.warning('请填写教育经历')
        //   return
        // }
        // if(that.model.trainingList.length === 0) {
        //   that.$message.warning('请填写培训经历')
        //   return
        // }
        // if(that.model.positionChangeRecordList.length === 0) {
        //   that.$message.warning('请填写职务变动')
        //   return
        // }
        // if(that.model.rewardPunishFileList.length === 0) {
        //   that.$message.warning('请填写奖惩档案')
        //   return
        // }
        // if(that.model.employeeCertificateList.length === 0) {
        //   that.$message.warning('请填写资质证书')
        //   return
        // }
        if (!that.model.postChangeRecordList || that.model.postChangeRecordList.length === 0) {
          that.$message.warning('请填写岗位信息')
          return
        }
        // 参保单位
        if (that.model.cbUnitInfoList && that.model.cbUnitInfoList.length) {
          // that.$message.warning('参保单位')
          // 判断参保单位中是否只含有一个currFlag == 1的数据
          if (!that.checkSingleFlag(that.model.cbUnitInfoList)) {
            that.$message.warning('参保单位信息中只能 有一个参保单位为是 的单位')
            return
          }
        }
        // 发薪单位
        // if (that.model.fxUnitInfoList && that.model.fxUnitInfoList.length) {
        //   if (!that.checkSingleFlag(that.model.fxUnitInfoList)) {
        //     that.$message.warning('发薪单位信息中只能 有一个发薪单位为是 的单位')
        //     return
        //   }
        // }
        // 公积金单位
        if (that.model.gjjUnitInfoList && that.model.gjjUnitInfoList.length) {
          if (!that.checkSingleFlag(that.model.gjjUnitInfoList)) {
            that.$message.warning('公积金单位信息中只能 有一个公积金单位为是 的单位')
            return
          }
        }
        if (valid) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          // this.$nextTick(() => {
          //   if (this.$refs.familySocialInfo) {
          //     let familySocialInfo = this.$refs.familySocialInfo.getSelectedRowKeys()
          //     this.model.familySocialInfoList = familySocialInfo
          //   }

          //   if (this.$refs.workHistory) {
          //     let workHistory = this.$refs.workHistory.getSelectedRowKeys()
          //     this.model.workHistoryList = workHistory
          //   }

          //   if (this.$refs.education) {
          //     let education = this.$refs.education.getSelectedRowKeys()
          //     this.model.educationList = education
          //   }

          //   if (this.$refs.training) {
          //     let training = this.$refs.training.getSelectedRowKeys()
          //     this.model.trainingList = training
          //   }

          //   if (this.$refs.rewardPunish) {
          //     let rewardPunish = this.$refs.rewardPunish.getSelectedRowKeys()
          //     this.model.rewardPunishFileList = rewardPunish
          //   }

          //   if (this.$refs.positionChangeRecord) {
          //     let positionChangeRecord = this.$refs.positionChangeRecord.getSelectedRowKeys()
          //     this.model.positionChangeRecordList = positionChangeRecord
          //   }

          //   if (this.$refs.certificate) {
          //     let certificate = this.$refs.certificate.getSelectedRowKeys()
          //     this.model.employeeCertificateList = certificate
          //   }
          // })
          httpAction(httpurl, this.model, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }
      })
    },
    clearPanelListDataSource() {
      // if (!this.model.id) {
      if (this.$refs.familySocialInfo) {
        if (!this.model.id) {
          this.$refs.familySocialInfo.selectedRowKeys = []
          let listUrl = this.$refs.familySocialInfo.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.familySocialInfo.url.list = listUrl
          this.$refs.familySocialInfo.loadData()
          // this.$refs.familySocialInfo.selectRows()
        } else {
          let listUrl = this.$refs.familySocialInfo.url.list0 + this.model.id
          this.$refs.familySocialInfo.url.list = listUrl
          this.$refs.familySocialInfo.loadData()
          this.$refs.familySocialInfo.selectRows()
        }
      }

      if (this.$refs.workHistory) {
        this.$refs.workHistory.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.workHistory.selectedRowKeys = []
          let listUrl = this.$refs.workHistory.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.workHistory.url.list = listUrl
          this.$refs.workHistory.loadData()
          // this.$refs.workHistory.selectRows()
        } else {
          let listUrl = this.$refs.workHistory.url.list0 + this.model.id
          this.$refs.workHistory.url.list = listUrl
          this.$refs.workHistory.loadData()
          this.$refs.workHistory.selectRows()
        }
      }

      if (this.$refs.education) {
        this.$refs.education.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.education.selectedRowKeys = []
          let listUrl = this.$refs.education.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.education.url.list = listUrl
          this.$refs.education.loadData()
          // this.$refs.education.selectRows()
        } else {
          let listUrl = this.$refs.education.url.list0 + this.model.id
          this.$refs.education.url.list = listUrl
          this.$refs.education.loadData()
          this.$refs.education.selectRows()
        }
      }

      if (this.$refs.training) {
        this.$refs.training.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.training.selectedRowKeys = []
          let listUrl = this.$refs.training.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.training.url.list = listUrl
          this.$refs.training.loadData()
          // this.$refs.training.selectRows()
        } else {
          let listUrl = this.$refs.training.url.list0 + this.model.id
          this.$refs.training.url.list = listUrl
          this.$refs.training.loadData()
          this.$refs.training.selectRows()
        }
      }

      if (this.$refs.rewardPunish) {
        this.$refs.rewardPunish.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.rewardPunish.selectedRowKeys = []
          let listUrl = this.$refs.rewardPunish.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.rewardPunish.url.list = listUrl
          this.$refs.rewardPunish.loadData()
          // this.$refs.rewardPunish.selectRows()
        } else {
          let listUrl = this.$refs.rewardPunish.url.list0 + this.model.id
          this.$refs.rewardPunish.url.list = listUrl
          this.$refs.rewardPunish.loadData()
          this.$refs.rewardPunish.selectRows()
        }
      }

      if (this.$refs.postChangeRecord) {
        this.$refs.postChangeRecord.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.postChangeRecord.selectedRowKeys = []
          let listUrl = this.$refs.postChangeRecord.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.postChangeRecord.url.list = listUrl
          this.$refs.postChangeRecord.loadData()
          // this.$refs.positionChangeRecord.selectRows()
        } else {
          let listUrl = this.$refs.postChangeRecord.url.list0 + this.model.id
          this.$refs.postChangeRecord.url.list = listUrl
          this.$refs.postChangeRecord.loadData()
          this.$refs.postChangeRecord.selectRows()
        }
      }

      if (this.$refs.positionChangeRecord) {
        this.$refs.positionChangeRecord.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.positionChangeRecord.selectedRowKeys = []
          let listUrl = this.$refs.positionChangeRecord.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.positionChangeRecord.url.list = listUrl
          this.$refs.positionChangeRecord.loadData()
          // this.$refs.positionChangeRecord.selectRows()
        } else {
          let listUrl = this.$refs.positionChangeRecord.url.list0 + this.model.id
          this.$refs.positionChangeRecord.url.list = listUrl
          this.$refs.positionChangeRecord.loadData()
          this.$refs.positionChangeRecord.selectRows()
        }
      }

      if (this.$refs.certificate) {
        this.$refs.certificate.selectedRowKeys = []
        if (!this.model.id) {
          this.$refs.certificate.selectedRowKeys = []
          let listUrl = this.$refs.certificate.url.list
          if (listUrl.indexOf('?') > 0) {
            listUrl = listUrl.substr(0, listUrl.indexOf('?'))
          }
          this.$refs.certificate.url.list = listUrl
          this.$refs.certificate.loadData()
          // this.$refs.familySocialInfo.selectRows()
        } else {
          let listUrl = this.$refs.certificate.url.list0 + this.model.id
          this.$refs.certificate.url.list = listUrl
          this.$refs.certificate.loadData()
          this.$refs.certificate.selectRows()
        }
      }
      // }
    }
  }
}
</script>
